#ifndef __MQTT_CHAT_
#define	__MQTT_CHAT_

#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "freertos/event_groups.h"
#include "esp_system.h"
#include "esp_wifi.h"
#include "esp_event.h"
#include "esp_log.h"
#include "time.h"
#include "mqtt_client.h"

#define MQTT_CHAT_MESSAGE_MAX   50

enum mqtt_message_dir{
    mqtt_message_send = 0,
    mqtt_message_rec
};

typedef struct _mqtt_chat_message{
    char *mes;
    enum mqtt_message_dir dir;
    struct tm *time;
}mqtt_chat_message;

typedef struct _mqtt_chat{
    mqtt_chat_message **message;
    size_t mes_point;
    size_t mes_num;
    char *who;
}mqtt_chat_obj;

esp_err_t mqtt_chat_init(esp_mqtt_client_handle_t *_mqttclient);
mqtt_chat_obj* mqtt_chat_new(const char *name);
void mqtt_chat_del(mqtt_chat_obj *chat);
esp_err_t mqtt_chat_rec_message(mqtt_chat_obj *chat, char *data);
esp_err_t mqtt_chat_send_message(mqtt_chat_obj *chat, char *data);

//======================临时测试=================
void mqtt_init(void);
//==============================================

#endif /* __MQTT_CHAT_ */

